package com.bwie.rent.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.rent.entity.ComplainEntity;
import com.bwie.rent.service.ComplainService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author lfw
 * @email sunlightcs@gmail.com
 * @date 2022-04-04 20:47:29
 */
@RestController
@RequestMapping("rent/complain")
public class ComplainController {
    @Autowired
    private  ComplainService complainService;

    /**
     * 投诉功能
     */
    @RequestMapping("/message")
    public R message(@RequestParam(value = "user",defaultValue = "-1") String user,@RequestBody ComplainEntity complainEntity){
        return complainService.compliain(user,complainEntity);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = complainService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{complainId}")
    public R info(@PathVariable("complainId") Integer complainId){
		ComplainEntity complain = complainService.getById(complainId);

        return R.ok().put("complain", complain);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ComplainEntity complain){
		complainService.save(complain);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ComplainEntity complain){
		complainService.updateById(complain);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] complainIds){
		complainService.removeByIds(Arrays.asList(complainIds));

        return R.ok();
    }

}
